using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.IO;

namespace Lu62Viewer
{
    public partial class FrmLu62 : Form
    {
        #region Constructors and initialization
        public FrmLu62()
        {
            InitializeComponent();
            initialize();
        }

        private void initialize()
        {
            scMain.Panel2Collapsed = true;
        }
        #endregion

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void splitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scMain.Panel2Collapsed = false;
            splitToolStripMenuItem.Enabled = false;
            closeSecondViewToolStripMenuItem.Enabled = true;
            compareSelectedSegmentToolStripMenuItem.Enabled = true;            
        }

        private void closeSecondViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scMain.Panel2Collapsed = true;
            splitToolStripMenuItem.Enabled = true;
            closeSecondViewToolStripMenuItem.Enabled = false;
            compareSelectedSegmentToolStripMenuItem.Enabled = false;
        }        

        private void compareSelectedSegmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                MySegmentNode segmentA = myLu62Viewer1.MySelectedSegmentNode;
                if (segmentA == null)
                    throw new ArgumentException("Devi selezionare un nodo nel pannello superiore");
                MySegmentNode segmentB = myLu62Viewer2.MySelectedSegmentNode;
                if (segmentB == null)
                    throw new ArgumentException("Devi selezionare un nodo nel pannello inferiore");
                MyCompareResult res = new MyCompareResult(segmentA, segmentB);                
                ErrorReport rep = new ErrorReport(res);
                rep.ShowDialog(this);                                          
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }           
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmAbout ab = new FrmAbout();
            ab.ShowDialog();
        }            
    }
}